package com.wdh.kjs.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.wdh.kjs.R;
import com.wdh.kjs.http.Httpurl;
import com.wdh.kjs.model.JsonModel_my;
import com.wdh.kjs.util.ToastUtils;

/**
 * Created by codingWw on 2016/3/7.
 */
public class Hc_more_Fragment extends Fragment implements View.OnClickListener{
    private JsonModel_my jsonModel_my;
    private TextView content_more;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_helpcenter_more, container, false);
        initView(view);
        loadData();
        return view;
    }

    private void loadData() {
        RequestParams params = new RequestParams();
        params.addBodyParameter("sign", "0");

        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, Httpurl.URL_PLATFORM_INFO, params, new RequestCallBack<String>() {

            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {

                Gson gson = new Gson();
                jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);
                Log.i("msg","666");
                if (jsonModel_my.success) {
                    if (jsonModel_my.getResult().size()>5)
                    content_more.setText(Html.fromHtml(jsonModel_my.getResult().get(5).getContent()));
                }
            }

            @Override
            public void onFailure(HttpException error, String msg) {
                ToastUtils.showShort(getActivity(), "网络异常！");
            }
        });

    }

    private void initView(View view) {
        content_more = (TextView)view.findViewById(R.id.content_more);
    }

    @Override
    public void onClick(View view) {

    }
}
